#ifndef EPOLLER_H
#define EPOLLER_H

#include <sys/epoll.h>
#include <fcntl.h>
#include <unistd.h>
#include <cassert>
#include <memory>
#include <vector>


class Epoller {
public:
    explicit Epoller(int max_events = 1024);
    ~Epoller();

    int add_fd(int fd, uint32_t events) const;
    int mod_fd(int fd, uint32_t events) const;
    int del_fd(int fd) const;
    int wait(int timeout_ms = -1);
    int get_event_fd(size_t i);
    uint32_t get_events(size_t i);


private:
    int m_epoll_fd;
    int m_max_events;
    std::vector<epoll_event> m_events;
};


#endif //EPOLLER_H
